package pacBioSimple;

import java.util.ArrayList;
import java.util.List;

import pacBiopackage.GetOpt;

public class SelectKmersByEntropy {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		GetOpt go = new GetOpt(args, "o:k:a:h:n:l:e:j");
		go.optErr = true;
		int ch = -1;
		
		// process options in command line arguments
		// Set default values
		boolean usagePrint = false;                 
		String filenameOutput="output.txt";
		String filenameKmerObject = "";
		boolean jelly =false;
		int kmer_count_limit =175;
		int left_border=0;
		double entropy=0.0;
		while ((ch = go.getopt()) != GetOpt.optEOF) 
		{
		    if ((char)ch == 'h') {
		       usagePrint = true;
		    }
		    else if((char)ch =='o')
		    {
		    	filenameOutput = go.optArgGet();
		    }
		    else if((char)ch =='n')
		    {
		    	kmer_count_limit=Integer.valueOf(go.optArgGet());
		    }
		    else if((char)ch =='k')
		    {
		    	filenameKmerObject=go.optArgGet();
		    }
		    else if((char)ch =='j')
		    {
		    	jelly=true;
		    }
		    else if((char)ch =='l')
		    {
		    	left_border=Integer.valueOf(go.optArgGet());
		    }
		    else if((char)ch =='e')
		    {
		    	entropy=Double.valueOf(go.optArgGet());
		    }
		    else
		        System.exit(1);                     // undefined option
		}                                           // getopt() returns '?'
		
		if (usagePrint || filenameKmerObject.isEmpty()) {
		    System.out.println("Usage: -k Kmer -n kmer_count_limit -l left -j -e entropy [ -o outputFile -h]"); //NOI18N
		    System.exit(0);
		}
		
		// @TODO check if files exist
	
		System.out.println("------------------------");
		System.out.println("Command line parameter settings:");
		System.out.println("-o " + filenameOutput); //NOI18N
		System.out.println("-n " + kmer_count_limit); //NOI18N
		System.out.println("-l " + left_border); //NOI18N
		System.out.println("-k " + filenameKmerObject); //NOI18N
		System.out.println("-j "+ jelly);
		System.out.println("-e "+ entropy);
		System.out.println("------------------------");
		
		List<Character> alphabet = new ArrayList<Character>();
		alphabet.add('A');
		alphabet.add('C');
		alphabet.add('G');
		alphabet.add('T');
		Entropy<Character>entropy_c = new Entropy<Character>(alphabet);
		MyUtil.selectKmerWithEntropyToFastq(entropy_c, jelly, filenameKmerObject, left_border, kmer_count_limit, entropy, filenameOutput);
	}

}
